package com.uwo.house.service.serviceImpl;

import com.uwo.house.beans.request.MessageReq;
import com.uwo.house.beans.response.*;
import com.uwo.house.dao.MessageDao;
import com.uwo.house.dao.SupplierMessageDao;
import com.uwo.house.service.IMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by YSTen on 2017/7/18.
 */
@Service
public class MessageService implements IMessageService {
    @Autowired
    private MessageDao messageDao;

    @Autowired
    private SupplierMessageDao supplierMessageDao;

    /**
     * 获取所有投诉对象
     *
     * @return
     */
    public List<MessageComplaintTypeResp> getAllComplaintResp() {
        return messageDao.getAllComplaintResp();
    }

    /**
     * 用户发起维护请求
     *
     * @param messageReq
     * @return
     */
    public int saveMessageForMaintain(MessageReq messageReq) {
        return messageDao.saveMessageForMaintain(messageReq);
    }

    /**
     * 用户发起投诉请求
     *
     * @param messageReq
     * @return
     */
    public int saveMessageForComplaint(MessageReq messageReq) {
        return messageDao.saveMessageForComplaint(messageReq);
    }

    /**
     * 根据ID获取message详细信息
     *
     * @param id
     * @return
     */
    public MessageResp getMessageDetail(int id) {
        return messageDao.getMessageDetail(id);
    }

    /**
     * 更新用户消息
     *
     * @param messageReq
     * @return
     */
    public int updateMessage(MessageReq messageReq) {
        return messageDao.updateMessage(messageReq);
    }

    /**
     * 获取用户消息
     *
     * @param messageReq
     * @return
     */
    public List<MessageResp> getAllMessage(MessageReq messageReq) {
        return messageDao.getAllMessage(messageReq);
    }

    /**
     * 删除用户消息
     *
     * @param id
     * @return
     */
    public int deleteMessage(int id) {
        messageDao.deleteSupplierMessage(id);
        return messageDao.deleteMessage(id);
    }

    public List<MessagesResp> getMessagesList(String orderId, String messageType, Integer handleStatus){
        return messageDao.getMessagesList(orderId,messageType,handleStatus);
    }

    public ClientInfoResp getClientInfo(String userId,String orderId){
        return messageDao.getClientInfo(userId,orderId);
    }

    public List<CustomerOrderResp> getUserOrders(String userId){
        return messageDao.getUserOrders(userId);
    }

    public List<StaffResp> getRelatedStaffs(String orderId) {
        return messageDao.getRelatedStaffs(orderId);
    }

    public String getManagerMobile(String orderId){
        return messageDao.getManagerMobile(orderId);
    }

    public String getCustomerMobile(int id){
        return messageDao.getCustomerMobile(id);
    }

    public int saveSupplierMessage(int messageId) {
        return supplierMessageDao.saveSupplierMessage(messageId);
    }
}
